package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Mobile      string `gorm:"type:varchar(100);not null;commit:'手机号码'"`
	Password    string `gorm:"type:varchar(100);not null;commit:'密码'"`
	OldPassword string `gorm:"type:varchar(100);not null;commit:'密码'"`
	NewPassword string `gorm:"type:varchar(100);not null;commit:'密码'"`
	SckPassword string `gorm:"type:varchar(100);not null;commit:'密码'"`
}

func (u *User) FindUser(db *gorm.DB, mobile string) error {
	return db.Debug().Where("mobile=?", mobile).FirstOrCreate(u).Error
}

func (u *User) FIndUserNAme(db *gorm.DB, id string) error {
	return db.Debug().Where("id=?", id).First(u).Error
}

func (u *User) Updated(db *gorm.DB, id string) error {
	return db.Debug().Where("id=?", id).Updates(u).Error
}
